home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / SpeechSynthesis.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  12.8 KB  |  418 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SpeechSynthesis.p
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1989-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT SpeechSynthesis;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __SPEECHSYNTHESIS__}
  28. {$SETC __SPEECHSYNTHESIS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC SpeechSynthesisIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __FILES__}
  41. {$I Files.p}
  42. {$ENDC}
  43.  
  44.  
  45. {$PUSH}
  46. {$ALIGN MAC68K}
  47. {$LibExport+}
  48.  
  49.  
  50. CONST
  51.     kTextToSpeechSynthType        = 'ttsc';
  52.     kTextToSpeechVoiceType        = 'ttvd';
  53.     kTextToSpeechVoiceFileType    = 'ttvf';
  54.     kTextToSpeechVoiceBundleType = 'ttvb';
  55.  
  56.     kNoEndingProsody            = 1;
  57.     kNoSpeechInterrupt            = 2;
  58.     kPreflightThenPause            = 4;
  59.  
  60.     kImmediate                    = 0;
  61.     kEndOfWord                    = 1;
  62.     kEndOfSentence                = 2;
  63.  
  64.  
  65. {------------------------------------------}
  66. { GetSpeechInfo & SetSpeechInfo selectors    }
  67. {------------------------------------------}
  68.     soStatus                    = 'stat';
  69.     soErrors                    = 'erro';
  70.     soInputMode                    = 'inpt';
  71.     soCharacterMode                = 'char';
  72.     soNumberMode                = 'nmbr';
  73.     soRate                        = 'rate';
  74.     soPitchBase                    = 'pbas';
  75.     soPitchMod                    = 'pmod';
  76.     soVolume                    = 'volm';
  77.     soSynthType                    = 'vers';
  78.     soRecentSync                = 'sync';
  79.     soPhonemeSymbols            = 'phsy';
  80.     soCurrentVoice                = 'cvox';
  81.     soCommandDelimiter            = 'dlim';
  82.     soReset                        = 'rset';
  83.     soCurrentA5                    = 'myA5';
  84.     soRefCon                    = 'refc';
  85.     soTextDoneCallBack            = 'tdcb';                        {  use with SpeechTextDoneProcPtr }
  86.     soSpeechDoneCallBack        = 'sdcb';                        {  use with SpeechDoneProcPtr }
  87.     soSyncCallBack                = 'sycb';                        {  use with SpeechSyncProcPtr }
  88.     soErrorCallBack                = 'ercb';                        {  use with SpeechErrorProcPtr }
  89.     soPhonemeCallBack            = 'phcb';                        {  use with SpeechPhonemeProcPtr }
  90.     soWordCallBack                = 'wdcb';
  91.     soSynthExtension            = 'xtnd';
  92.     soSoundOutput                = 'sndo';
  93.  
  94.  
  95. {------------------------------------------}
  96. { Speaking Mode Constants                     }
  97. {------------------------------------------}
  98.     modeText                    = 'TEXT';                        {  input mode constants                      }
  99.     modePhonemes                = 'PHON';
  100.     modeNormal                    = 'NORM';                        {  character mode and number mode constants  }
  101.     modeLiteral                    = 'LTRL';
  102.  
  103.  
  104.     soVoiceDescription            = 'info';
  105.     soVoiceFile                    = 'fref';
  106.  
  107.  
  108.  
  109. TYPE
  110.     SpeechChannelRecordPtr = ^SpeechChannelRecord;
  111.     SpeechChannelRecord = RECORD
  112.         data:                    ARRAY [0..0] OF LONGINT;
  113.     END;
  114.  
  115.     SpeechChannel                        = ^SpeechChannelRecord;
  116.  
  117.     VoiceSpecPtr = ^VoiceSpec;
  118.     VoiceSpec = RECORD
  119.         creator:                OSType;
  120.         id:                        OSType;
  121.     END;
  122.  
  123.  
  124.  
  125. CONST
  126.     kNeuter                        = 0;
  127.     kMale                        = 1;
  128.     kFemale                        = 2;
  129.  
  130.  
  131.  
  132.  
  133.  
  134. TYPE
  135.     VoiceDescriptionPtr = ^VoiceDescription;
  136.     VoiceDescription = RECORD
  137.         length:                    LONGINT;
  138.         voice:                    VoiceSpec;
  139.         version:                LONGINT;
  140.         name:                    Str63;
  141.         comment:                Str255;
  142.         gender:                    INTEGER;
  143.         age:                    INTEGER;
  144.         script:                    INTEGER;
  145.         language:                INTEGER;
  146.         region:                    INTEGER;
  147.         reserved:                ARRAY [0..3] OF LONGINT;
  148.     END;
  149.  
  150.  
  151.  
  152.     VoiceFileInfoPtr = ^VoiceFileInfo;
  153.     VoiceFileInfo = RECORD
  154.         fileSpec:                FSSpec;
  155.         resID:                    INTEGER;
  156.     END;
  157.  
  158.     SpeechStatusInfoPtr = ^SpeechStatusInfo;
  159.     SpeechStatusInfo = RECORD
  160.         outputBusy:                BOOLEAN;
  161.         outputPaused:            BOOLEAN;
  162.         inputBytesLeft:            LONGINT;
  163.         phonemeCode:            INTEGER;
  164.     END;
  165.  
  166.  
  167.  
  168.     SpeechErrorInfoPtr = ^SpeechErrorInfo;
  169.     SpeechErrorInfo = RECORD
  170.         count:                    INTEGER;
  171.         oldest:                    OSErr;
  172.         oldPos:                    LONGINT;
  173.         newest:                    OSErr;
  174.         newPos:                    LONGINT;
  175.     END;
  176.  
  177.  
  178.  
  179.     SpeechVersionInfoPtr = ^SpeechVersionInfo;
  180.     SpeechVersionInfo = RECORD
  181.         synthType:                OSType;
  182.         synthSubType:            OSType;
  183.         synthManufacturer:        OSType;
  184.         synthFlags:                LONGINT;
  185.         synthVersion:            NumVersion;
  186.     END;
  187.  
  188.  
  189.  
  190.     PhonemeInfoPtr = ^PhonemeInfo;
  191.     PhonemeInfo = RECORD
  192.         opcode:                    INTEGER;
  193.         phStr:                    Str15;
  194.         exampleStr:                Str31;
  195.         hiliteStart:            INTEGER;
  196.         hiliteEnd:                INTEGER;
  197.     END;
  198.  
  199.  
  200.     PhonemeDescriptorPtr = ^PhonemeDescriptor;
  201.     PhonemeDescriptor = RECORD
  202.         phonemeCount:            INTEGER;
  203.         thePhonemes:            ARRAY [0..0] OF PhonemeInfo;
  204.     END;
  205.  
  206.     SpeechXtndDataPtr = ^SpeechXtndData;
  207.     SpeechXtndData = PACKED RECORD
  208.         synthCreator:            OSType;
  209.         synthData:                PACKED ARRAY [0..1] OF Byte;
  210.     END;
  211.  
  212.  
  213.     DelimiterInfoPtr = ^DelimiterInfo;
  214.     DelimiterInfo = PACKED RECORD
  215.         startDelimiter:            PACKED ARRAY [0..1] OF Byte;
  216.         endDelimiter:            PACKED ARRAY [0..1] OF Byte;
  217.     END;
  218.  
  219.  
  220.     SpeechTextDoneProcPtr = ProcPtr;  { PROCEDURE SpeechTextDone(chan: SpeechChannel; refCon: LONGINT; VAR nextBuf: UNIV Ptr; VAR byteLen: LONGINT; VAR controlFlags: LONGINT); }
  221.  
  222.     SpeechDoneProcPtr = ProcPtr;  { PROCEDURE SpeechDone(chan: SpeechChannel; refCon: LONGINT); }
  223.  
  224.     SpeechSyncProcPtr = ProcPtr;  { PROCEDURE SpeechSync(chan: SpeechChannel; refCon: LONGINT; syncMessage: OSType); }
  225.  
  226.     SpeechErrorProcPtr = ProcPtr;  { PROCEDURE SpeechError(chan: SpeechChannel; refCon: LONGINT; theError: OSErr; bytePos: LONGINT); }
  227.  
  228.     SpeechPhonemeProcPtr = ProcPtr;  { PROCEDURE SpeechPhoneme(chan: SpeechChannel; refCon: LONGINT; phonemeOpcode: INTEGER); }
  229.  
  230.     SpeechWordProcPtr = ProcPtr;  { PROCEDURE SpeechWord(chan: SpeechChannel; refCon: LONGINT; wordPos: LONGINT; wordLen: INTEGER); }
  231.  
  232.     SpeechTextDoneUPP = UniversalProcPtr;
  233.     SpeechDoneUPP = UniversalProcPtr;
  234.     SpeechSyncUPP = UniversalProcPtr;
  235.     SpeechErrorUPP = UniversalProcPtr;
  236.     SpeechPhonemeUPP = UniversalProcPtr;
  237.     SpeechWordUPP = UniversalProcPtr;
  238.  
  239. CONST
  240.     uppSpeechTextDoneProcInfo = $0000FFC0;
  241.     uppSpeechDoneProcInfo = $000003C0;
  242.     uppSpeechSyncProcInfo = $00000FC0;
  243.     uppSpeechErrorProcInfo = $00003BC0;
  244.     uppSpeechPhonemeProcInfo = $00000BC0;
  245.     uppSpeechWordProcInfo = $00002FC0;
  246.  
  247. FUNCTION NewSpeechTextDoneProc(userRoutine: SpeechTextDoneProcPtr): SpeechTextDoneUPP;
  248.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  249.     INLINE $2E9F;
  250.     {$ENDC}
  251.  
  252. FUNCTION NewSpeechDoneProc(userRoutine: SpeechDoneProcPtr): SpeechDoneUPP;
  253.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  254.     INLINE $2E9F;
  255.     {$ENDC}
  256.  
  257. FUNCTION NewSpeechSyncProc(userRoutine: SpeechSyncProcPtr): SpeechSyncUPP;
  258.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  259.     INLINE $2E9F;
  260.     {$ENDC}
  261.  
  262. FUNCTION NewSpeechErrorProc(userRoutine: SpeechErrorProcPtr): SpeechErrorUPP;
  263.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  264.     INLINE $2E9F;
  265.     {$ENDC}
  266.  
  267. FUNCTION NewSpeechPhonemeProc(userRoutine: SpeechPhonemeProcPtr): SpeechPhonemeUPP;
  268.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  269.     INLINE $2E9F;
  270.     {$ENDC}
  271.  
  272. FUNCTION NewSpeechWordProc(userRoutine: SpeechWordProcPtr): SpeechWordUPP;
  273.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  274.     INLINE $2E9F;
  275.     {$ENDC}
  276.  
  277. PROCEDURE CallSpeechTextDoneProc(chan: SpeechChannel; refCon: LONGINT; VAR nextBuf: UNIV Ptr; VAR byteLen: LONGINT; VAR controlFlags: LONGINT; userRoutine: SpeechTextDoneUPP);
  278.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  279.     INLINE $205F, $4E90;
  280.     {$ENDC}
  281.  
  282. PROCEDURE CallSpeechDoneProc(chan: SpeechChannel; refCon: LONGINT; userRoutine: SpeechDoneUPP);
  283.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  284.     INLINE $205F, $4E90;
  285.     {$ENDC}
  286.  
  287. PROCEDURE CallSpeechSyncProc(chan: SpeechChannel; refCon: LONGINT; syncMessage: OSType; userRoutine: SpeechSyncUPP);
  288.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  289.     INLINE $205F, $4E90;
  290.     {$ENDC}
  291.  
  292. PROCEDURE CallSpeechErrorProc(chan: SpeechChannel; refCon: LONGINT; theError: OSErr; bytePos: LONGINT; userRoutine: SpeechErrorUPP);
  293.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  294.     INLINE $205F, $4E90;
  295.     {$ENDC}
  296.  
  297. PROCEDURE CallSpeechPhonemeProc(chan: SpeechChannel; refCon: LONGINT; phonemeOpcode: INTEGER; userRoutine: SpeechPhonemeUPP);
  298.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  299.     INLINE $205F, $4E90;
  300.     {$ENDC}
  301.  
  302. PROCEDURE CallSpeechWordProc(chan: SpeechChannel; refCon: LONGINT; wordPos: LONGINT; wordLen: INTEGER; userRoutine: SpeechWordUPP);
  303.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  304.     INLINE $205F, $4E90;
  305.     {$ENDC}
  306. FUNCTION SpeechManagerVersion: NumVersion;
  307.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  308.     INLINE $203C, $0000, $000C, $A800;
  309.     {$ENDC}
  310. FUNCTION MakeVoiceSpec(creator: OSType; id: OSType; VAR voice: VoiceSpec): OSErr;
  311.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  312.     INLINE $203C, $0604, $000C, $A800;
  313.     {$ENDC}
  314. FUNCTION CountVoices(VAR numVoices: INTEGER): OSErr;
  315.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  316.     INLINE $203C, $0108, $000C, $A800;
  317.     {$ENDC}
  318. FUNCTION GetIndVoice(index: INTEGER; VAR voice: VoiceSpec): OSErr;
  319.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  320.     INLINE $203C, $030C, $000C, $A800;
  321.     {$ENDC}
  322. FUNCTION GetVoiceDescription({CONST}VAR voice: VoiceSpec; VAR info: VoiceDescription; infoLength: LONGINT): OSErr;
  323.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  324.     INLINE $203C, $0610, $000C, $A800;
  325.     {$ENDC}
  326. FUNCTION GetVoiceInfo({CONST}VAR voice: VoiceSpec; selector: OSType; voiceInfo: UNIV Ptr): OSErr;
  327.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  328.     INLINE $203C, $0614, $000C, $A800;
  329.     {$ENDC}
  330. FUNCTION NewSpeechChannel(voice: VoiceSpecPtr; VAR chan: SpeechChannel): OSErr;
  331.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  332.     INLINE $203C, $0418, $000C, $A800;
  333.     {$ENDC}
  334. FUNCTION DisposeSpeechChannel(chan: SpeechChannel): OSErr;
  335.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  336.     INLINE $203C, $021C, $000C, $A800;
  337.     {$ENDC}
  338. FUNCTION SpeakString(textToBeSpoken: ConstStr255Param): OSErr;
  339.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  340.     INLINE $203C, $0220, $000C, $A800;
  341.     {$ENDC}
  342. FUNCTION SpeakText(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: LONGINT): OSErr;
  343.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  344.     INLINE $203C, $0624, $000C, $A800;
  345.     {$ENDC}
  346. FUNCTION SpeakBuffer(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: LONGINT; controlFlags: LONGINT): OSErr;
  347.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  348.     INLINE $203C, $0828, $000C, $A800;
  349.     {$ENDC}
  350. FUNCTION StopSpeech(chan: SpeechChannel): OSErr;
  351.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  352.     INLINE $203C, $022C, $000C, $A800;
  353.     {$ENDC}
  354. FUNCTION StopSpeechAt(chan: SpeechChannel; whereToStop: LONGINT): OSErr;
  355.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  356.     INLINE $203C, $0430, $000C, $A800;
  357.     {$ENDC}
  358. FUNCTION PauseSpeechAt(chan: SpeechChannel; whereToPause: LONGINT): OSErr;
  359.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  360.     INLINE $203C, $0434, $000C, $A800;
  361.     {$ENDC}
  362. FUNCTION ContinueSpeech(chan: SpeechChannel): OSErr;
  363.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  364.     INLINE $203C, $0238, $000C, $A800;
  365.     {$ENDC}
  366. FUNCTION SpeechBusy: INTEGER;
  367.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  368.     INLINE $203C, $003C, $000C, $A800;
  369.     {$ENDC}
  370. FUNCTION SpeechBusySystemWide: INTEGER;
  371.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  372.     INLINE $203C, $0040, $000C, $A800;
  373.     {$ENDC}
  374. FUNCTION SetSpeechRate(chan: SpeechChannel; rate: Fixed): OSErr;
  375.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  376.     INLINE $203C, $0444, $000C, $A800;
  377.     {$ENDC}
  378. FUNCTION GetSpeechRate(chan: SpeechChannel; VAR rate: Fixed): OSErr;
  379.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  380.     INLINE $203C, $0448, $000C, $A800;
  381.     {$ENDC}
  382. FUNCTION SetSpeechPitch(chan: SpeechChannel; pitch: Fixed): OSErr;
  383.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  384.     INLINE $203C, $044C, $000C, $A800;
  385.     {$ENDC}
  386. FUNCTION GetSpeechPitch(chan: SpeechChannel; VAR pitch: Fixed): OSErr;
  387.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  388.     INLINE $203C, $0450, $000C, $A800;
  389.     {$ENDC}
  390. FUNCTION SetSpeechInfo(chan: SpeechChannel; selector: OSType; speechInfo: UNIV Ptr): OSErr;
  391.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  392.     INLINE $203C, $0654, $000C, $A800;
  393.     {$ENDC}
  394. FUNCTION GetSpeechInfo(chan: SpeechChannel; selector: OSType; speechInfo: UNIV Ptr): OSErr;
  395.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  396.     INLINE $203C, $0658, $000C, $A800;
  397.     {$ENDC}
  398. FUNCTION TextToPhonemes(chan: SpeechChannel; textBuf: UNIV Ptr; textBytes: LONGINT; phonemeBuf: Handle; VAR phonemeBytes: LONGINT): OSErr;
  399.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  400.     INLINE $203C, $0A5C, $000C, $A800;
  401.     {$ENDC}
  402. FUNCTION UseDictionary(chan: SpeechChannel; dictionary: Handle): OSErr;
  403.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  404.     INLINE $203C, $0460, $000C, $A800;
  405.     {$ENDC}
  406.  
  407.  
  408. {$ALIGN RESET}
  409. {$POP}
  410.  
  411. {$SETC UsingIncludes := SpeechSynthesisIncludes}
  412.  
  413. {$ENDC} {__SPEECHSYNTHESIS__}
  414.  
  415. {$IFC NOT UsingIncludes}
  416.  END.
  417. {$ENDC}
  418.